﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using FXnaWpfBase;

using System.Windows.Controls;


using FXnaGis;

using FXnaInfrastructure;



namespace FXnaAppBaseWpf
{
    public class VectorImageCollectionVM:MDTVIViewModel
    {
        public VectorImageCollectionVM(MDTVIViewModel parent,FEntityCollection collection)
            : base(parent)
        {
            this._contextMenu = new System.Windows.Controls.ContextMenu();

            MenuItem mi = new MenuItem();
            mi.Header = "导入DWG文件";
            mi.Command = AppBaseCommands.AddDWGFile;

            this._contextMenu.Items.Add(mi);




            this._vectorLayers = collection;

            this._vectorLayers.EntityAdded += new EventHandler<EntityEventArgs>(_vectorLayers_EntityAdded);

            this._vectorLayers.EntityRemoved += new EventHandler<EntityEventArgs>(_vectorLayers_EntityRemoved);


            this.LoadChildren();



           

        }

        void _vectorLayers_EntityRemoved(object sender, EntityEventArgs e)
        {
            this.Children.Clear();

            this.LoadChildren();

        }

        void _vectorLayers_EntityAdded(object sender, EntityEventArgs e)
        {
            this.Children.Clear();

            this.LoadChildren();


        }

        public override string Desc
        {
            get
            {
                return "矢量图集合";
            }
        }

        FEntityCollection _vectorLayers;


       


        protected override void LoadChildren()
        {

            foreach (FGroupLayer item in this._vectorLayers.Entities)
            {
                VectorImageVM img = new VectorImageVM(this,item);

                this.Children.Add(img);
                
            }

        }

    }
}
